import { createApp } from 'vue';
// 导入第三方组件
import mitt from 'mitt';

// 导入App组件(充当根组件)
import App from '@/App.vue';

import ShoppingCart from '@/components/ShoppingCart.vue';
import CartItem from '@/components/CartItem.vue';
import CartTotal from '@/components/CartTotal.vue';

// 创建应用
const app = createApp(App);
console.log( 'application: ' , app );

// 定义全局属性
app.config.globalProperties.$eventBus = mitt();
app.config.globalProperties.$amountChange = '数量改变';
app.config.globalProperties.$removeItem = '删除商品条目';

// 全局注册组件
app.component( 'shopping-cart' , ShoppingCart );
app.component( 'cart-item' , CartItem );
app.component( 'cart-total' , CartTotal );

// 挂载
const root = app.mount('#app');
console.log( 'root: ' , root );


